<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>The Statistics Collector</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Monitoring Database Activity"
HREF="monitoring.html"><LINK
REL="PREVIOUS"
TITLE="Standard Unix Tools"
HREF="monitoring-ps.html"><LINK
REL="NEXT"
TITLE="Viewing Locks"
HREF="monitoring-locks.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="Standard Unix Tools"
HREF="monitoring-ps.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="monitoring.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 27. Monitoring Database Activity</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="Viewing Locks"
HREF="monitoring-locks.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="MONITORING-STATS"
>27.2. The Statistics Collector</A
></H1
><P
>   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>'s <I
CLASS="FIRSTTERM"
>statistics collector</I
>
   is a subsystem that supports collection and reporting of information about
   server activity.  Presently, the collector can count accesses to tables
   and indexes in both disk-block and individual-row terms.  It also tracks
   the total number of rows in each table, and information about vacuum and
   analyze actions for each table.  It can also count calls to user-defined
   functions and the total time spent in each one.
  </P
><P
>   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> also supports reporting of the exact
   command currently being executed by other server processes.  This
   facility is independent of the collector process.
  </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="MONITORING-STATS-SETUP"
>27.2.1. Statistics Collection Configuration</A
></H2
><P
>   Since collection of statistics adds some overhead to query execution,
   the system can be configured to collect or not collect information.
   This is controlled by configuration parameters that are normally set in
   <TT
CLASS="FILENAME"
>postgresql.conf</TT
>.  (See <A
HREF="runtime-config.html"
>Chapter 18</A
> for
   details about setting configuration parameters.)
  </P
><P
>   The parameter <A
HREF="runtime-config-statistics.html#GUC-TRACK-COUNTS"
>track_counts</A
> controls whether
   statistics are collected about table and index accesses.
  </P
><P
>   The parameter <A
HREF="runtime-config-statistics.html#GUC-TRACK-FUNCTIONS"
>track_functions</A
> enables tracking of
   usage of user-defined functions.
  </P
><P
>   The parameter <A
HREF="runtime-config-statistics.html#GUC-TRACK-ACTIVITIES"
>track_activities</A
> enables monitoring
   of the current command being executed by any server process.
  </P
><P
>   Normally these parameters are set in <TT
CLASS="FILENAME"
>postgresql.conf</TT
> so
   that they apply to all server processes, but it is possible to turn
   them on or off in individual sessions using the <A
HREF="sql-set.html"
>SET</A
> command. (To prevent
   ordinary users from hiding their activity from the administrator,
   only superusers are allowed to change these parameters with
   <TT
CLASS="COMMAND"
>SET</TT
>.)
  </P
><P
>   The statistics collector transmits the collected
   information to backends (including autovacuum) through temporary files.
   These files are stored in the <TT
CLASS="FILENAME"
>pg_stat_tmp</TT
> subdirectory.
   When the postmaster shuts down, a permanent copy of the statistics
   data is stored in the <TT
CLASS="FILENAME"
>global</TT
> subdirectory. For increased
   performance, the parameter <A
HREF="runtime-config-statistics.html#GUC-STATS-TEMP-DIRECTORY"
>stats_temp_directory</A
> can
   be pointed at a RAM-based file system, decreasing physical I/O requirements.
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="MONITORING-STATS-VIEWS"
>27.2.2. Viewing Collected Statistics</A
></H2
><P
>   Several predefined views, listed in <A
HREF="monitoring-stats.html#MONITORING-STATS-VIEWS-TABLE"
>Table 27-1</A
>, are available to show the results
   of statistics collection.  Alternatively, one can
   build custom views using the underlying statistics functions.
  </P
><P
>   When using the statistics to monitor current activity, it is important
   to realize that the information does not update instantaneously.
   Each individual server process transmits new statistical counts to
   the collector just before going idle; so a query or transaction still in
   progress does not affect the displayed totals.  Also, the collector itself
   emits a new report at most once per <TT
CLASS="VARNAME"
>PGSTAT_STAT_INTERVAL</TT
>
   milliseconds (500 unless altered while building the server).  So the
   displayed information lags behind actual activity.  However, current-query
   information collected by <TT
CLASS="VARNAME"
>track_activities</TT
> is
   always up-to-date.
  </P
><P
>   Another important point is that when a server process is asked to display
   any of these statistics, it first fetches the most recent report emitted by
   the collector process and then continues to use this snapshot for all
   statistical views and functions until the end of its current transaction.
   So the statistics will show static information as long as you continue the
   current transaction.  Similarly, information about the current queries of
   all sessions is collected when any such information is first requested
   within a transaction, and the same information will be displayed throughout
   the transaction.
   This is a feature, not a bug, because it allows you to perform several
   queries on the statistics and correlate the results without worrying that
   the numbers are changing underneath you.  But if you want to see new
   results with each query, be sure to do the queries outside any transaction
   block.  Alternatively, you can invoke
   <CODE
CLASS="FUNCTION"
>pg_stat_clear_snapshot</CODE
>(), which will discard the
   current transaction's statistics snapshot (if any).  The next use of
   statistical information will cause a new snapshot to be fetched.
  </P
><P
>   A transaction can also see its own statistics (as yet untransmitted to the
   collector) in the views <TT
CLASS="STRUCTNAME"
>pg_stat_xact_all_tables</TT
>,
   <TT
CLASS="STRUCTNAME"
>pg_stat_xact_sys_tables</TT
>,
   <TT
CLASS="STRUCTNAME"
>pg_stat_xact_user_tables</TT
>, and
   <TT
CLASS="STRUCTNAME"
>pg_stat_xact_user_functions</TT
>, or via these views' underlying
   functions.  These numbers do not act as stated above; instead they update
   continuously throughout the transaction.
  </P
><DIV
CLASS="TABLE"
><A
NAME="MONITORING-STATS-VIEWS-TABLE"
></A
><P
><B
>Table 27-1. Standard Statistics Views</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>View Name</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_activity</TT
></TD
><TD
>One row per server process, showing database OID, database
      name, process <ACRONYM
CLASS="ACRONYM"
>ID</ACRONYM
>, user OID, user name, application name,
      client's address, host name (if available), and port number, times at
      which the server process, current transaction, and current query began
      execution, process's waiting status, and text of the current query.
      The columns that report data on the current query are available unless
      the parameter <TT
CLASS="VARNAME"
>track_activities</TT
> has been turned off.
      Furthermore, these columns are only visible if the user examining
      the view is a superuser or the same as the user owning the process
      being reported on.  The client's host name will be available only if
      <A
HREF="runtime-config-logging.html#GUC-LOG-HOSTNAME"
>log_hostname</A
> is set or if the user's host name
      needed to be looked up during <TT
CLASS="FILENAME"
>pg_hba.conf</TT
>
      processing.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_bgwriter</TT
></TD
><TD
>One row only, showing cluster-wide statistics from the
      background writer: number of scheduled checkpoints, requested
      checkpoints, buffers written by checkpoints and cleaning scans,
      and the number of times the background writer stopped a cleaning scan
      because it had written too many buffers.  Also includes
      statistics about the shared buffer pool, including buffers written
      by backends (that is, not by the background writer), how many times
      those backends had to execute their own fsync calls (normally the
      background writer handles those even when the backend does its own
      write), total buffers allocated, and time of last statistics reset.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_database</TT
></TD
><TD
>One row per database, showing database OID, database name,
      number of active server processes connected to that database,
      number of transactions committed and rolled back in that database,
      total disk blocks read, total buffer hits (i.e., block
      read requests avoided by finding the block already in buffer cache),
      number of rows returned, fetched, inserted, updated and deleted, the
      total number of queries canceled due to conflict with recovery (on
      standby servers), and time of last statistics reset.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_database_conflicts</TT
></TD
><TD
>One row per database, showing database OID, database name and
      the number of queries that have been canceled in this database due to
      dropped tablespaces, lock timeouts, old snapshots, pinned buffers and
      deadlocks. Will only contain information on standby servers, since
      conflicts do not occur on master servers.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_replication</TT
></TD
><TD
>One row per WAL sender process, showing process <ACRONYM
CLASS="ACRONYM"
>ID</ACRONYM
>,
      user OID, user name, application name, client's address, host name
      (if available) and port number, time at which the server process began
      execution, and the current WAL sender state and transaction log
      location.  In addition, the standby reports the last transaction log
      position it received and wrote, the last position it flushed to disk,
      and the last position it replayed, and this information is also
      displayed here. If the standby's application names matches one of the
      settings in <TT
CLASS="VARNAME"
>synchronous_standby_names</TT
> then the sync_priority
      is shown here also, that is the order in which standbys will become
      the synchronous standby. The columns detailing what exactly the connection
      is doing are only visible if the user examining the view is a superuser.
      The client's host name will be available only if
      <A
HREF="runtime-config-logging.html#GUC-LOG-HOSTNAME"
>log_hostname</A
> is set or if the user's host name
      needed to be looked up during <TT
CLASS="FILENAME"
>pg_hba.conf</TT
>
      processing.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
></TD
><TD
>For each table in the current database (including TOAST tables),
      the table OID, schema and table name, number of sequential
      scans initiated, number of live rows fetched by sequential
      scans, number of index scans initiated (over all indexes
      belonging to the table), number of live rows fetched by index
      scans, numbers of row insertions, updates, and deletions,
      number of row updates that were HOT (i.e., no separate index update),
      numbers of live and dead rows,
      the last time the table was non-<TT
CLASS="OPTION"
>FULL</TT
> vacuumed manually,
      the last time it was vacuumed by the autovacuum daemon,
      the last time it was analyzed manually,
      the last time it was analyzed by the autovacuum daemon,
      number of times it has been non-<TT
CLASS="OPTION"
>FULL</TT
> vacuumed manually,
      number of times it has been vacuumed by the autovacuum daemon,
      number of times it has been analyzed manually,
      and the number of times it has been analyzed by the autovacuum daemon.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_sys_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
>, except that only
      system tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_user_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
>, except that only user
      tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_xact_all_tables</TT
></TD
><TD
>Similar to <TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
>, but counts actions
      taken so far within the current transaction (which are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
>
      yet included in <TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
> and related views).
      The columns for numbers of live and dead rows and vacuum and
      analyze actions are not present in this view.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_xact_sys_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_xact_all_tables</TT
>, except that only
      system tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_xact_user_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_xact_all_tables</TT
>, except that only
      user tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_all_indexes</TT
></TD
><TD
>For each index in the current database,
      the table and index OID, schema, table and index name,
      number of index scans initiated on that index, number of
      index entries returned by index scans, and number of live table rows
      fetched by simple index scans using that index.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_sys_indexes</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_all_indexes</TT
>, except that only
      indexes on system tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_user_indexes</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_stat_all_indexes</TT
>, except that only
      indexes on user tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_all_tables</TT
></TD
><TD
>For each table in the current database (including TOAST tables),
      the table OID, schema and table name, number of disk
      blocks read from that table, number of buffer hits, numbers of
      disk blocks read and buffer hits in all indexes of that table,
      numbers of disk blocks read and buffer hits from that table's
      auxiliary TOAST table (if any), and numbers of disk blocks read
      and buffer hits for the TOAST table's index.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_sys_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_tables</TT
>, except that only
      system tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_user_tables</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_tables</TT
>, except that only
      user tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_all_indexes</TT
></TD
><TD
>For each index in the current database,
      the table and index OID, schema, table and index name,
      numbers of disk blocks read and buffer hits in that index.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_sys_indexes</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_indexes</TT
>, except that only
      indexes on system tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_user_indexes</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_indexes</TT
>, except that only
      indexes on user tables are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_all_sequences</TT
></TD
><TD
>For each sequence object in the current database,
      the sequence OID, schema and sequence name,
      numbers of disk blocks read and buffer hits in that sequence.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_sys_sequences</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_sequences</TT
>, except that only
      system sequences are shown.  (Presently, no system sequences are defined,
      so this view is always empty.)</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_statio_user_sequences</TT
></TD
><TD
>Same as <TT
CLASS="STRUCTNAME"
>pg_statio_all_sequences</TT
>, except that only
      user sequences are shown.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_user_functions</TT
></TD
><TD
>For all tracked functions, function OID, schema, name, number
      of calls, total time, and self time.  Self time is the
      amount of time spent in the function itself, total time includes the
      time spent in functions it called. Time values are in milliseconds.
     </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTNAME"
>pg_stat_xact_user_functions</TT
></TD
><TD
>Similar to <TT
CLASS="STRUCTNAME"
>pg_stat_user_functions</TT
>, but counts only
      calls during the current transaction (which are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
>
      yet included in <TT
CLASS="STRUCTNAME"
>pg_stat_user_functions</TT
>).</TD
></TR
></TBODY
></TABLE
></DIV
><P
>   The per-index statistics are particularly useful to determine which
   indexes are being used and how effective they are.
  </P
><P
>   Indexes can be
   used either directly or via <SPAN
CLASS="QUOTE"
>"bitmap scans"</SPAN
>.  In a bitmap scan
   the output of several indexes can be combined via AND or OR rules;
   so it is difficult to associate individual heap row fetches
   with specific indexes when a bitmap scan is used.  Therefore, a bitmap
   scan increments the
   <TT
CLASS="STRUCTNAME"
>pg_stat_all_indexes</TT
>.<TT
CLASS="STRUCTFIELD"
>idx_tup_read</TT
>
   count(s) for the index(es) it uses, and it increments the
   <TT
CLASS="STRUCTNAME"
>pg_stat_all_tables</TT
>.<TT
CLASS="STRUCTFIELD"
>idx_tup_fetch</TT
>
   count for the table, but it does not affect
   <TT
CLASS="STRUCTNAME"
>pg_stat_all_indexes</TT
>.<TT
CLASS="STRUCTFIELD"
>idx_tup_fetch</TT
>.
  </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>    Before <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> 8.1, the
    <TT
CLASS="STRUCTFIELD"
>idx_tup_read</TT
> and <TT
CLASS="STRUCTFIELD"
>idx_tup_fetch</TT
> counts
    were essentially always equal.  Now they can be different even without
    considering bitmap scans, because <TT
CLASS="STRUCTFIELD"
>idx_tup_read</TT
> counts
    index entries retrieved from the index while <TT
CLASS="STRUCTFIELD"
>idx_tup_fetch</TT
>
    counts live rows fetched from the table; the latter will be less if any
    dead or not-yet-committed rows are fetched using the index.
   </P
></BLOCKQUOTE
></DIV
><P
>   The <TT
CLASS="STRUCTNAME"
>pg_statio_</TT
> views are primarily useful to
   determine the effectiveness of the buffer cache.  When the number
   of actual disk reads is much smaller than the number of buffer
   hits, then the cache is satisfying most read requests without
   invoking a kernel call. However, these statistics do not give the
   entire story: due to the way in which <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>
   handles disk I/O, data that is not in the
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> buffer cache might still reside in the
   kernel's I/O cache, and might therefore still be fetched without
   requiring a physical read. Users interested in obtaining more
   detailed information on <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> I/O behavior are
   advised to use the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> statistics collector
   in combination with operating system utilities that allow insight
   into the kernel's handling of I/O.
  </P
><P
>   Other ways of looking at the statistics can be set up by writing
   queries that use the same underlying statistics access functions as
   these standard views do.  These functions are listed in <A
HREF="monitoring-stats.html#MONITORING-STATS-FUNCS-TABLE"
>Table 27-2</A
>.  The per-database access
   functions take a database OID as argument to identify which
   database to report on.  The per-table and per-index functions take
   a table or index OID.  The functions for function-call statistics
   take a function OID.  (Note that only tables, indexes, and functions
   in the current database can be seen with these functions.)  The
   per-server-process access functions take a server process
   number, which ranges from one to the number of currently active
   server processes.
  </P
><DIV
CLASS="TABLE"
><A
NAME="MONITORING-STATS-FUNCS-TABLE"
></A
><P
><B
>Table 27-2. Statistics Access Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Function</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_numbackends</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>       Number of active server processes for database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_xact_commit</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of transactions committed in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_xact_rollback</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of transactions rolled back in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_blocks_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block fetch requests for database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_blocks_hit</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block fetch requests found in cache for database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_tuples_returned</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of tuples returned for database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_tuples_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of tuples fetched for database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_tuples_inserted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of tuples inserted in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_tuples_updated</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of tuples updated in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_tuples_deleted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of tuples deleted in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_conflict_tablespace</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of queries canceled because of recovery conflict with dropped tablespaces in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_conflict_lock</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of queries canceled because of recovery conflict with locks in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_conflict_snapshot</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of queries canceled because of recovery conflict with old snapshots in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_conflict_bufferpin</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of queries canceled because of recovery conflict with pinned buffers in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_conflict_startup_deadlock</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of queries canceled because of recovery conflict with deadlocks in database
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_db_stat_reset_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>       Time of the last statistics reset for the database.  Initialized to the
       system time during the first connection to each database.  The reset time
       is updated when you call <CODE
CLASS="FUNCTION"
>pg_stat_reset</CODE
> on the
       database, as well as upon execution of
       <CODE
CLASS="FUNCTION"
>pg_stat_reset_single_table_counters</CODE
> against any
       table or index in it.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_numscans</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of sequential scans done when argument is a table,
       or number of index scans done when argument is an index
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_returned</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows read by sequential scans when argument is a table,
       or number of index entries returned when argument is an index
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of table rows fetched by bitmap scans when argument is a table,
       or table rows fetched by simple index scans using the index
       when argument is an index
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_inserted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows inserted into table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_updated</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows updated in table (includes HOT updates)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_deleted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows deleted from table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_tuples_hot_updated</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows HOT-updated in table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_live_tuples</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of live rows in table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_dead_tuples</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of dead rows in table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_blocks_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block fetch requests for table or index
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_blocks_hit</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block requests found in cache for table or index
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_last_vacuum_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>       Time of the last non-<TT
CLASS="OPTION"
>FULL</TT
> vacuum initiated by the user on this table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_last_autovacuum_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>       Time of the last vacuum initiated by the autovacuum daemon on this table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_last_analyze_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>       Time of the last analyze initiated by the user on this table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_last_autoanalyze_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>       Time of the last analyze initiated by the autovacuum daemon on this
       table
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_vacuum_count</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       The number of times this table has been non-<TT
CLASS="OPTION"
>FULL</TT
> vacuumed manually
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_autovacuum_count</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       The number of times this table has been vacuumed by the autovacuum daemon
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_analyze_count</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       The number of times this table has been analyzed manually
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_autoanalyze_count</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       The number of times this table has been analyzed by the autovacuum daemon
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_numscans</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of sequential scans done when argument is a table,
       or number of index scans done when argument is an index, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_returned</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows read by sequential scans when argument is a table,
       or number of index entries returned when argument is an index, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of table rows fetched by bitmap scans when argument is a table,
       or table rows fetched by simple index scans using the index
       when argument is an index, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_inserted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows inserted into table, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_updated</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows updated in table (includes HOT updates), in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_deleted</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows deleted from table, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_tuples_hot_updated</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of rows HOT-updated in table, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_blocks_fetched</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block fetch requests for table or index, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_blocks_hit</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of disk block requests found in cache for table or index, in the current transaction
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_backend_pid()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>       Process ID of the server process attached to the current session
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_activity</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>setof record</TT
></TD
><TD
>       Returns a record of information about the backend with the specified PID, or
       one record for each active backend in the system if <TT
CLASS="SYMBOL"
>NULL</TT
> is
       specified. The fields returned are a subset of those in the
       <TT
CLASS="STRUCTNAME"
>pg_stat_activity</TT
> view.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_function_calls</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of times the function has been called
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_function_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Total wall clock time spent in the function, in microseconds.  Includes
       the time spent in functions called by this one.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_function_self_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Time spent in only this function. Time spent in called functions
       is excluded.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_function_calls</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of times the function has been called, in the current transaction.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_function_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Total wall clock time spent in the function, in microseconds, in the
       current transaction.  Includes the time spent in functions called by
       this one.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_xact_function_self_time</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Time spent in only this function, in the current transaction. Time
       spent in called functions is excluded.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_idset()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>setof integer</TT
></TD
><TD
>       Set of currently active server process numbers (from 1 to the
       number of active server processes).  See usage example in the text.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_pid</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>       Process ID of the given server process
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_dbid</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
>       Database ID of the given server process
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_userid</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
>       User ID of the given server process
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_activity</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>       Active command of the given server process, but only if the
       current user is a superuser or the same user as that of
       the session being queried (and
       <TT
CLASS="VARNAME"
>track_activities</TT
> is on)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_waiting</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>       True if the given server process is waiting for a lock,
       but only if the current user is a superuser or the same user as that of
       the session being queried (and
       <TT
CLASS="VARNAME"
>track_activities</TT
> is on)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_activity_start</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamp with time zone</TT
></TD
><TD
>       The time at which the given server process' currently
       executing query was started, but only if the
       current user is a superuser or the same user as that of
       the session being queried (and
       <TT
CLASS="VARNAME"
>track_activities</TT
> is on)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_xact_start</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamp with time zone</TT
></TD
><TD
>       The time at which the given server process' currently
       executing transaction was started, but only if the
       current user is a superuser or the same user as that of
       the session being queried (and
       <TT
CLASS="VARNAME"
>track_activities</TT
> is on)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_start</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamp with time zone</TT
></TD
><TD
>       The time at which the given server process was started, or
       null if the current user is not a superuser nor the same user
       as that of the session being queried
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_client_addr</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>inet</TT
></TD
><TD
>       The IP address of the client connected to the given
       server process; null if the connection is over a Unix domain
       socket, also null if the current user is not a superuser nor
       the same user as that of the session being queried
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_backend_client_port</CODE
>(<TT
CLASS="TYPE"
>integer</TT
>)</TT
></TD
><TD
><TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>       The TCP port number of the client connected to the given
       server process; -1 if the connection is over a Unix domain
       socket, null if the current user is not a superuser nor the
       same user as that of the session being queried
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_timed_checkpoints()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>        Number of times the background writer has started timed checkpoints
        (because the <TT
CLASS="VARNAME"
>checkpoint_timeout</TT
> time has expired)
       </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_requested_checkpoints()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of times the background writer has started checkpoints based
       on requests from backends because the <TT
CLASS="VARNAME"
>checkpoint_segments</TT
>
       has been exceeded or because the <TT
CLASS="COMMAND"
>CHECKPOINT</TT
>
       command has been issued
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_buf_written_checkpoints()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of buffers written by the background writer during checkpoints
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_buf_written_clean()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of buffers written by the background writer for routine cleaning of
       dirty pages
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_maxwritten_clean()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of times the background writer has stopped its cleaning scan because
       it has written more buffers than specified in the
       <TT
CLASS="VARNAME"
>bgwriter_lru_maxpages</TT
> parameter
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_bgwriter_stat_reset_time()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>timestamptz</TT
></TD
><TD
>        Time of the last statistics reset for the background writer, updated
        when executing <CODE
CLASS="FUNCTION"
>pg_stat_reset_shared('bgwriter')</CODE
>
        on the database cluster.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_buf_written_backend()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Number of buffers written by backends because they needed
       to allocate a new buffer
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_get_buf_alloc()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>       Total number of buffer allocations
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_clear_snapshot()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>       Discard the current statistics snapshot
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_reset()</CODE
></TT
></TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>       Reset all statistics counters for the current database to zero
       (requires superuser privileges)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_reset_shared</CODE
>(text)</TT
></TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>       Reset some of the shared statistics counters for the database cluster to
       zero (requires superuser privileges).  Calling
       <TT
CLASS="LITERAL"
>pg_stat_reset_shared('bgwriter')</TT
> will zero all the values shown by
       <TT
CLASS="STRUCTNAME"
>pg_stat_bgwriter</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_reset_single_table_counters</CODE
>(oid)</TT
></TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>       Reset statistics for a single table or index in the current database to
       zero (requires superuser privileges)
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_reset_single_function_counters</CODE
>(oid)</TT
></TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>       Reset statistics for a single function in the current database to
       zero (requires superuser privileges)
      </TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>     <CODE
CLASS="FUNCTION"
>pg_stat_get_blocks_fetched</CODE
> minus
     <CODE
CLASS="FUNCTION"
>pg_stat_get_blocks_hit</CODE
> gives the number of kernel
     <CODE
CLASS="FUNCTION"
>read()</CODE
> calls issued for the table, index, or
     database; the number of actual physical reads is usually
     lower due to kernel-level buffering.  The <TT
CLASS="LITERAL"
>*_blks_read</TT
>
     statistics columns use this subtraction, i.e., fetched minus hit.
    </P
></BLOCKQUOTE
></DIV
><P
>   All functions to access information about backends are indexed by backend id
   number, except <CODE
CLASS="FUNCTION"
>pg_stat_get_activity</CODE
> which is indexed by PID.
   The function <CODE
CLASS="FUNCTION"
>pg_stat_get_backend_idset</CODE
> provides
   a convenient way to generate one row for each active server process.  For
   example, to show the <ACRONYM
CLASS="ACRONYM"
>PID</ACRONYM
>s and current queries of all server processes:

</P><PRE
CLASS="PROGRAMLISTING"
>SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
       pg_stat_get_backend_activity(s.backendid) AS current_query
    FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;</PRE
><P>
  </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="monitoring-ps.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="monitoring-locks.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Standard Unix Tools</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="monitoring.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Viewing Locks</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>